﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orid.Data.SqlServer;

namespace Orid.Management.Statistics.Tools.Decomposition.Data
{
    class StoreServersOnline:StoreServers
    {
        public string GetDBAddress(string ID)
        {
            try
            {
                string connectString = Config.Setting.SettingInstance.DBAddress_Online;

                StringBuilder sqlText = new StringBuilder();
                sqlText.Append(" SELECT	 [AccessInformation]");
                sqlText.Append("  FROM  [FutureManagement_Masters].[FutureMa].[StoreServers] [StoreServers]  with(NOLOCK)");
                sqlText.Append("  WHERE [StoreServerID] = @StoreServerID");
          

                using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connectString))
                {
                    conn.Open();
                    System.Data.SqlClient.SqlParameter[] SqlParameter;
                    SqlParameter = new System.Data.SqlClient.SqlParameter[]
                                 {     
                                       new System.Data.SqlClient.SqlParameter("@StoreServerID" ,ID)
                                 };

                  

                   string  AccessInformation  = SqlHelper.ExecuteScalar(conn, System.Data.CommandType.Text, sqlText.ToString(), SqlParameter).ToString();
          
                   if (conn.State == System.Data.ConnectionState.Open)
                        conn.Close();

                   return AccessInformation;

                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw (new Exception(ex.Message));
            }
            
        }
    }
}
